package com.ruoyi.complaint.service.impl;

import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.complaint.entity.*;
import com.ruoyi.complaint.mapper.ComplaintDao;
import com.ruoyi.complaint.service.ComplaintService;
import com.ruoyi.system.api.domain.SysRole;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: user  <br/>
 * Date: 2022/4/21:11:06  <br/>
 * Description:
 */
@Service
public class ComplaintServiceImpl implements ComplaintService {
    @Autowired
    private ComplaintDao complaintMapper;

    @Override
    public List<Complaint> getall(Complaint complaint) {
        List<Complaint> getall = complaintMapper.getall(complaint);
        System.out.println("--------------------------------------------------------------------");
        System.out.println(getall);
        System.out.println("--------------------------------------------------------------------");
        return getall;
    }
    @Override
    public List<Complaint> getall2(Complaint complaint) {
        List<Complaint> getall = complaintMapper.getall2(complaint);
        System.out.println("--------------------------------------------------------------------");
        System.out.println(getall);
        System.out.println("--------------------------------------------------------------------");
        return getall;
    }

    @Override
    public boolean ignoreComplaint(int id) {
        return complaintMapper.ignoreComplaint(id) > 0;
    }

    @Override
    public boolean rollbackComplaint(int id) {
        return complaintMapper.rollbackComplaint(id) > 0;
    }

    @Override
    public DTO getStatics(int id) {
        DTO dto = new DTO();
        Complaint complaint = new Complaint();
        complaint.setOrderNumber(String.valueOf(id));
        complaint = complaintMapper.getall(complaint).get(0);
        dto.setComplaint(complaint);
        OrderContract orderContract = complaintMapper.getOrderContract(id);
        dto.setOrderContract(orderContract);
        WayBill wayBill = complaintMapper.getWayBill(orderContract.getWaybillNumber());
        dto.setWayBill(wayBill);
        Contract contract = complaintMapper.getContract(wayBill.getWaybillId());
        dto.setContract(contract);
        dto.setUser(complaintMapper.getUser(complaint.getCustomerId()));
        dto.setDriver(complaintMapper.getDriver(contract.getDriverId()));
        return dto;
    }

    @Override
    public boolean changeStatus(int id, String name,int status) {

        return complaintMapper.changeStatus(id, name,status) > 0;
    }


    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public Complaint selectComplaintById(Long id) {
        return complaintMapper.selectComplaintById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param complaint 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<Complaint> selectComplaintList(Complaint complaint) {
        return complaintMapper.selectComplaintList(complaint);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param complaint 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertComplaint(Complaint complaint) {
        return complaintMapper.insertComplaint(complaint);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param complaint 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateComplaint(Complaint complaint) {
        return complaintMapper.updateComplaint(complaint);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteComplaintByIds(Long[] ids) {
        return complaintMapper.deleteComplaintByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteComplaintById(Long id) {
        return complaintMapper.deleteComplaintById(id);
    }

}
